Class Input extends Box
public var doEnter;
public var doChange;
var field;
var form;
var color="#000";
var fontSize=24;
var maxLength;
var align="left";
var type="text";
var placeholder;
var multi=false;
var readOnly=false;
var text="";
function Input(){
	while(this.div.children.length>0){
		this.div.removeChild(this.div.children[0]);
	}
	this.field=document.createElement("input");
	this.div.appendChild(this.field);
	this.field.style.cssText="width:100%;height:100%;font-size:24px;padding:5px;"+G.toCssKey("box-sizing")+":border-box;background:transparent;border:none;outline:medium";
	this.field.selectable=true;
	this.field.oninput=this.onFieldInput;
	this.div.style[G.toCssKey("TouchCallout")]="initial";
	this.div.style[G.toCssKey("UserSelect")]="initial";
	this.setSize(400,36);
}
function resetSelf(){
	if(this.doEnter&&!this.form&&this.type=="text"){
		this.form=document.createElement("form");
		this.div.appendChild(this.form);
		this.form.style.cssText="width:100%;height:100%";
		this.form.appendChild(this.field);
		this.form.onsubmit=this.onFormSubmit;
	}
}
public function focus(){
	callLater([this.field,this.field.focus],100);
}
public function blur(){
	callLater([this.field,this.field.blur],100);
}
public function scrollEnd(){
	this.field.scrollTop=this.field.scrollHeight;
}
public function setSize(w,h){
	Box.proto.setSize.call(this,w,h);
	this.changeSelf();
}
public function setColor(v){
	this.color=v;
	this.field.style.color=G.toColor(v);
}
public function setFontSize(v){
	this.fontSize=v;
	this.field.style.fontSize=v+"px";
}
public function setMaxLength(v){
	this.maxLength=v;
	this.field.maxLength=v;
}
public function setAlign(v){
	this.align=v;
	this.field.style.textAlign=v;
}
public function setType(v){
	this.type=v;
	this.field.type=v;
}
public function setPlaceholder(v){
	this.placeholder=v;
	this.field.placeholder=v;
}
public function getText(){
	return this.field.value;
}
public function setText(v){
	this.text=v;
	this.field.value=v;
	call(this.doChange);
}
public function setReadOnly(v){
	this.readOnly=v;
	this.field.readOnly=v;
}
public function setMulti(v){
	if(this.multi==v) return;
	this.multi=v;
	var field0=this.field;
	this.div.removeChild(field0);
	this.field=document.createElement(v?"textarea":"input");
	this.div.appendChild(this.field);
	if(v){
		this.field[G.toCssKey("OverflowScrolling")]="touch";
		this.field.scroll=true;
	}
	this.field.oninput=this.onFieldInput;
	this.field.selectable=true;
	this.field.style.cssText=field0.style.cssText;
	this.field.value=field0.value;
	this.field.readOnly=field0.readOnly;
	this.field.wrap="soft";
}
function onFormSubmit(evt){
	var caller=evt.target.parentNode.box;
	call(caller.doEnter);
	return false;
}
function onFieldInput(evt){
	var target=evt.target.parentNode;
	if(target.tagName=="FORM"){
		target=target.parentNode;
	}
	var caller=target.box;
	caller.text=evt.target.value;
	call(caller.doChange);
}